package com.ctg.payroll2.action.workflow;

import java.util.List;

import org.apache.struts2.ServletActionContext;

import com.ctg.payroll2.bean.po.workflow.FlowOrgchart;
import com.ctg.payroll2.service.workflow.WorkflowOrgChartService;
import com.ctg.payroll2.util.FlowOrgchartMenuRecursion;
import com.opensymphony.xwork2.ActionSupport;

public class WorkflowOrgChartAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4320244822145214315L;
	// JSON 返回 拼装的 jsonString
	private String jsonString = "";

	public String getJsonString() {

		return jsonString;
	}

	public void setJsonString(String jsonString) {

		this.jsonString = jsonString;

	}

	private WorkflowOrgChartService workflowOrgChartService;

	
	
	public void setWorkflowOrgChartService(
			WorkflowOrgChartService workflowOrgChartService) {
		this.workflowOrgChartService = workflowOrgChartService;
	}

	// 得到申请书类型，绑定到类型树
	public String orgChartTree() {

		try {
			String id = ServletActionContext.getRequest().getParameter("node");//id参数 现在无用  SQL里没用到
			List<FlowOrgchart> list = workflowOrgChartService.getOrgCharts();

			if (list != null && !list.isEmpty()) {
				//MenuRecursion 拼装menuTree类 
				jsonString = FlowOrgchartMenuRecursion.getString(list);
			}

		} catch (Exception e) {

			// TODO Auto-generated catch block

			e.printStackTrace();

		}

		return SUCCESS;
	}

}